<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>可拖拽菜单</title>
    <style>
        table,td{
            border-color: #f2f2f2;
        }
        img {
            width: 100px;
            height: 100px;
        }
    </style>
    <script>
        function dragIt(e) {
            e.dataTransfer.setData("Text",e.target.id);
        }
        function overIt(e) {
            e.preventDefault();
        }
        function dropIt(e) {
            e.preventDefault();
            var dragId=e.dataTransfer.getData("Text");
            e.target.appendChild(document.getElementById(dragId));
        }
        function removeIt() {
            var fruit=document.getElementById("fruit");
            var lastChild=fruit.lastChild;
            fruit.removeChild(lastChild);
        }
    </script>
</head>
<body>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
    <tr>
        <td colspan="3" align="center">
            <b>请将选择的菜品和果品拖曳至对应顾客下方区域</b>
        </td>
    </tr>
    <tr>
        <td width="30%"><p>顾客A</p></td>
        <td width="30%"><p>顾客B</p></td>
        <td width="30%"><p>顾客C</p></td>
    </tr>
    <tr >
        <td width="30%" ondrop="dropIt(event);" ondragover="overIt(event);">
            &nbsp;
        </td>
        <td width="30%" ondrop="dropIt(event);" ondragover="overIt(event);">
            &nbsp;
        </td>
        <td width="30%"  ondrop="dropIt(event);" ondragover="overIt(event);">
            &nbsp;
        </td>
    </tr>
</table>
<br/><br/>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
    <tr>
        <td width="80%"><p>可选择的菜品及果品</p></td>
        <td width="20%"><p>删除</p></td>
    </tr>

    <tr>
        <td id="fruit" width="80%" ondrop="dropIt(event);" ondragover="overIt(event);">
            <img src="../tupian/1.png" id="I1" draggable="true" ondragstart="dragIt(event);"/>
            <img src="../tupian/2.png" id="I2" draggable="true" ondragstart="dragIt(event);"/>
            <img src="../tupian/3.png" id="I3" draggable="true" ondragstart="dragIt(event);"/>
            <img src="../tupian/4.jpg" id="I4" draggable="true" ondragstart="dragIt(event);"/>
            <img src="../tupian/1.png" id="I5" draggable="true" ondragstart="dragIt(event);"/>
            <img src="../tupian/2.png" id="I6" draggable="true" ondragstart="dragIt(event);"/>
            <img src="../tupian/3.png" id="I7" draggable="true" ondragstart="dragIt(event);"/>
            <img src="../tupian/4.jpg" id="I8" draggable="true" ondragstart="dragIt(event);"/>
            <img src="../tupian/1.png" id="I9" draggable="true" ondragstart="dragIt(event);"/>
            <img src="../tupian/2.png" id="I10" draggable="true" ondragstart="dragIt(event);"/>
            <img src="../tupian/3.png" id="I11" draggable="true" ondragstart="dragIt(event);"/>
            <img src="../tupian/4.jpg" id="I12" draggable="true" ondragstart="dragIt(event);"/>
        </td>
        <td width="20%">
            <button type="button" onclick="removeIt();">删除</button>
        </td>
    </tr>
</table>
</body>
</html>